package com.hzit.sk.mq.customer;

import com.hzit.sk.mq.CreateOrderReq;
import com.hzit.sk.service.IOrderService;
import com.rabbitmq.client.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 生成订单的消费者
 */
@Component
@RabbitListener(bindings =@QueueBinding(
        value = @Queue(value = "skill.queue",autoDelete = "true"),
        exchange = @Exchange(value = "skill.exchange.topic" ,type = "topic"),
        key ="send.*" ))
public class CreateOrderCustomer {

    @Autowired
    private IOrderService orderService;

    Logger logger = LoggerFactory.getLogger(CreateOrderCustomer.class);


    @RabbitHandler
    public void createOrder(CreateOrderReq createOrderReq, Channel channel){

        logger.info("-------------createOrderReq----"+ createOrderReq);

        //生成订单的代码 TODO

        orderService.createOreder(createOrderReq);



    }


}
